package CtrLayer;

import java.sql.Date;
import java.util.ArrayList;

import ModelLayer.*;
import DBLayer.*;

public class CtrContract {
	private IFDBContract dbCon;

	public CtrContract() {
		dbCon = DBContract.getInstance();
	}
	
	public ArrayList<Contract> searchRandom(String searchF) {
		return dbCon.searchRandom(searchF);
	}
	
	public int getContractsExpiringThisMonth(){
		return dbCon.getContractsExpiringThisMonth();
	}
	
	public int getContractsExpiringNextTwoMonths(){
		return dbCon.getContractsExpiringNextTwoMonths();
	}
	
	
	public ArrayList<Contract> getAll_where(String wClause){
		return dbCon.getAllContracts_where(wClause);
	}
	
	public ArrayList<Contract> getAllContracts() {
		return dbCon.getAllContracts();
	}

	public Contract getContract_byContractId(int contractId) {
		return dbCon.getContract_byContractId(contractId);
	}

	public ArrayList<Contract> getContract_byApartmentId(int apartId) {
		return dbCon.getContract_byApartmentId(apartId);
	}

	public Contract getContract_byTenantId(int tenantId) {
		return dbCon.getContract_byTenantId(tenantId);
	}
	
	public Contract getContract_byTenantName(String tenantName) {
		return dbCon.getContract_byTenantName(tenantName);
	}

	public ArrayList<Contract> getContract_byTenant_or_ByLandlord_Name(String name) {
		return dbCon.getContract_byTenant_or_ByLandlord_Name(name);
	}

	public int insert(int contractId, int period, Apartment apartment, Date startDate, double monthlyRent, double depositAmount, Tenant tenant) {
		return dbCon.insert(new Contract(-1, period, apartment, startDate, tenant));
	}
	
	public int insert(Contract contr) {
		return dbCon.insert(contr);
	}

	public int update(int contractId, int period, Apartment apartment, Date startDate, double monthlyRent, double depositAmount, Tenant tenant, boolean updateCommissionSimilar) {
		return dbCon.update(new Contract(contractId, period, apartment, startDate, tenant),updateCommissionSimilar);
	}
	
	public int update(Contract contr, boolean updateCommissionSimilar){
		return dbCon.update(contr,updateCommissionSimilar);
	}

	public int delete(int contractId) {
		return dbCon.delete(contractId);
	}

	
}
